//
//  HashrateVC.m
//  WalletAPP
//
//  Created by 罗弟祥 on 2019/10/10.
//  Copyright © 2019 罗弟祥. All rights reserved.
//

#import "HashrateNaviVC.h"
#import "FSScrollContentView.h"
#import "HashrateTeamVC.h"
@interface HashrateNaviVC ()<FSPageContentViewDelegate,FSSegmentTitleViewDelegate>{
    
}

@property (nonatomic, retain) FSPageContentView *pageContentView;

@property (nonatomic, strong) FSSegmentTitleView *titleView;
@property (nonatomic, retain) NSArray *titleArr;//标题数组

@property (nonatomic, retain) NaviView *naviView;

@end

@implementation HashrateNaviVC

- (void)viewDidLoad {
    [super viewDidLoad];
    // Do any additional setup after loading the view from its nib.
    
    [self.view addSubview:self.naviView];
    self.naviView.frame = CGRectMake(0, 0, screenW, StatusBarHeight + NavBarHeight);
    self.naviView.titStr = @"Hashrate";
//    [self.naviView.rightBtn setTitle:@"Down" forState:UIControlStateNormal];
//    [self.naviView.rightBtn addTarget:self action:@selector(rightBtnClick:) forControlEvents:UIControlEventTouchUpInside];
//    self.naviView.rightBtn.hidden = NO;
    [self.naviView setBackBlock:^{
        [self.navigationController popViewControllerAnimated:YES];
    }];
    
    
    [self.view addSubview:self.titleView];
    [self addPageContentView];
}
-(void)rightBtnClick:(UIButton *)sender{
    
}
-(void)viewDidLayoutSubviews{
    [super viewDidLayoutSubviews];
    self.naviView.frame = CGRectMake(0, 0, screenW, StatusBarHeight + NavBarHeight);

}

-(NaviView *)naviView{
    if (!_naviView) {
        _naviView = [[NSBundle mainBundle] loadNibNamed:NSStringFromClass([NaviView class]) owner:self options:nil].firstObject;
    }
    return _naviView;
}

-(FSSegmentTitleView *)titleView{
    if (!_titleView) {
        
        _titleView = [[FSSegmentTitleView alloc]initWithFrame:CGRectMake(0, StatusBarHeight + NavBarHeight, screenW, 50) titles:self.titleArr delegate:self indicatorType:FSIndicatorTypeEqualsWidth];
        _titleView.indicatorExtension = -5;
        _titleView.indicatorScale = 0.4;
        _titleView.indicatorHeight = 3;
        _titleView.titleBottom = 5;
        _titleView.buttonType = FSTypeDefault;
        _titleView.titleSelectFont = [UIFont systemFontOfSize:18];
        _titleView.titleNormalColor = DEF_0xColor(0x9EA9C3, 1);
        _titleView.titleSelectColor = DEF_0xColor(0x3E4ABE, 1);
        _titleView.indicatorColor = DEF_0xColor(0x3E4ABE, 1);
        _titleView.backgroundColor = [UIColor clearColor];
        if (@available(iOS 11.0, *)) {
            
        }else{
//            [_titleView setMj_h:44];
        }
    }
    return _titleView;
}


-(NSArray *)titleArr{
    return @[@"Hashrate TOP team",@"My team"];
    
}

-(void)addPageContentView{
    NSMutableArray *contentVCs = [NSMutableArray array];
    for (NSInteger i = 0; i < self.titleArr.count; i++) {
        
        HashrateTeamVC *vc = [[HashrateTeamVC alloc]init];
        vc.index = i;
        [contentVCs addObject:vc];
    }
    if (!_pageContentView) {
        _pageContentView = [[FSPageContentView alloc]initWithFrame:CGRectMake(0, 50 + StatusBarHeight + NavBarHeight, screenW, screenH - StatusBarHeight - NavBarHeight) childVCs:contentVCs parentVC:self delegate:self];
        [self.view addSubview:_pageContentView];
    }
}



#pragma mark FSSegmentTitleViewDelegate
- (void)FSContenViewDidEndDecelerating:(FSPageContentView *)contentView startIndex:(NSInteger)startIndex endIndex:(NSInteger)endIndex
{
    self.titleView.selectIndex = endIndex;
}

- (void)FSSegmentTitleView:(FSSegmentTitleView *)titleView startIndex:(NSInteger)startIndex endIndex:(NSInteger)endIndex
{
    self.pageContentView.contentViewCurrentIndex = endIndex;
}

- (void)FSContentViewDidScroll:(FSPageContentView *)contentView startIndex:(NSInteger)startIndex endIndex:(NSInteger)endIndex progress:(CGFloat)progress{
    
}

#pragma mark UIScrollView
- (void)scrollViewDidScroll:(UIScrollView *)scrollView{
    
}


/*
#pragma mark - Navigation

// In a storyboard-based application, you will often want to do a little preparation before navigation
- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender {
    // Get the new view controller using [segue destinationViewController].
    // Pass the selected object to the new view controller.
}
*/

@end
